import { TAllTypes, IPosition, IValue, IAllPosition } from '../types';
export interface IPositionValue {
  getValue(position:IAllPosition): IValue[];
}
export abstract class AFunc {
  constructor(protected positionVal: IPositionValue) {

  }
  protected transformToRangeValue(val: TAllTypes): IValue[][] {
    if(val.type === 'value') {
      return [[val]];
    }
    if(val.type === 'position') {
      let _val = this.positionVal.getValue(val);
      return [_val];
    }
    if(val.type === 'colPosition') {
      let _val: IValue[][] = [];
      let temp = this.positionVal.getValue(val);
      for(let item of temp) {
        _val.push([item]);
      }
      return _val;
    }
    if(val.type === 'rowPosition') {
      let _val: IValue[] = [];
      let temp = this.positionVal.getValue(val);
      for(let item of temp) {
        _val.push(item);
      }
      return [_val];
    }
    if(val.type === 'range') {
      return val.value.getMatrixValues() as any;
    }
    return [];
  }
  public abstract excute(args: TAllTypes[]):TAllTypes[];
}

